﻿using Microsoft.Extensions.DependencyInjection;

namespace 依赖注入案例练习;

class Program
{
    static void Main(string[] args)
    {
        ServiceCollection service = new ServiceCollection();
        // service.AddScoped<IConfig, Config>();
        //service.AddScoped(typeof(IConfig), s => new IniFileConfig() { FilePath = "mail.ini" });
        // service.AddScoped<ILog, Log>();
        // service.AddScoped<IMailService, MailService>();

        //service.AddConfig();
        service.AddReaderImpl();
        service.AddIniFileConfig("mail.ini");
        service.AddConfig();
        service.AddMailService();
        service.AddLog();

        using (var sp = service.BuildServiceProvider())
        {
            var maileService = sp.GetRequiredService<IMailService>();
            maileService.Send("test", "123@qq.com", "hhhhh");
        }
    }
}
